package com.yunxi.controller.sto;

import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.ResponseUtil;
import com.yunxi.sto.pojo.DailyReportVO;
import com.yunxi.sto.pojo.MonthlyReportVO;
import com.yunxi.sto.pojo.YearReportVO;
import com.yunxi.sto.service.DailyReportDubboService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 基础报告 前端控制器
 * </p>
 *
 * @author caoYong
 * @since 2019-09-20
 */
@RestController
@RequestMapping("/admin/dailyReport")
@Api(tags = "sto:dailyReport", description = "基础报告接口")
public class DailyReportController {
    private static final Logger logger = LoggerFactory.getLogger(DailyReportController.class);

    @Autowired
    DailyReportDubboService dailyReportDubboService;

    @GetMapping("/page")
    @ApiOperation(value = "日报表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "pageNum", value = "分页页码", required = true, dataType = "int"),
            @ApiImplicitParam(paramType="query", name = "pageSize", value = "分页数量", required = true, dataType = "int")
    })
    public ApiResult page(DailyReportVO dailyReportVO, Integer pageNum, Integer pageSize) throws Exception {
        return ResponseUtil.ok(dailyReportDubboService.dayPage(dailyReportVO, pageNum, pageSize));
    }

    @GetMapping("/dayPage")
    @ApiOperation(value = "日报表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "pageNum", value = "分页页码", required = true, dataType = "int"),
            @ApiImplicitParam(paramType="query", name = "pageSize", value = "分页数量", required = true, dataType = "int")
    })
    public ApiResult dayPage(DailyReportVO dailyReportVO, Integer pageNum, Integer pageSize) throws Exception {
        return ResponseUtil.ok(dailyReportDubboService.dayPage(dailyReportVO, pageNum, pageSize));
    }

    @GetMapping("/dayCalcMain")
    @ApiOperation(value = "日报表计算")
    @ApiImplicitParams({
    })
    public ApiResult dayCalcMain(DailyReportVO dailyReportVO) throws Exception {
        dailyReportDubboService.dayCalcMain(dailyReportVO);
        return ResponseUtil.ok();
    }

    @GetMapping("/monthCalcMain")
    @ApiOperation(value = "月报表计算接口")
    public ApiResult monthCalcMain(MonthlyReportVO monthlyReportVO) throws Exception {
        dailyReportDubboService.monthCalcMain(monthlyReportVO);
        return ResponseUtil.ok();
    }

    @GetMapping("/monthPage")
    @ApiOperation(value = "月报表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "pageNum", value = "分页页码", required = true, dataType = "int"),
            @ApiImplicitParam(paramType="query", name = "pageSize", value = "分页数量", required = true, dataType = "int")
    })
    public ApiResult monthPage(MonthlyReportVO monthlyReportVO, Integer pageNum, Integer pageSize) throws Exception {
        return ResponseUtil.ok(dailyReportDubboService.monthPage3(monthlyReportVO, pageNum, pageSize));
    }

    @GetMapping("/yearPage")
    @ApiOperation(value = "年报表")
    public ApiResult yearPage(YearReportVO yearReportVO, Integer pageNum, Integer pageSize) throws Exception {
        return ResponseUtil.ok(dailyReportDubboService.yearList3(yearReportVO, pageNum, pageSize));
    }

    @GetMapping("/yearCalcMain")
    @ApiOperation(value = "年报表计算接口")
    public ApiResult yearPage3(YearReportVO yearReportVO) throws Exception {
        dailyReportDubboService.yearCalcMain(yearReportVO);
        return ResponseUtil.ok();
    }
}
